FROM golang:alpine as builder
ENV GOPROXY https://goproxy.cn
WORKDIR /cache
COPY go.mod .
COPY go.sum .
RUN go mod download
WORKDIR /build
COPY . /build/
RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -installsuffix cgo -ldflags '-s -w -extldflags "-static"' -o main ./run.go
FROM alpine
RUN apk add -U tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
COPY --from=builder /build/main /app/
WORKDIR /app
CMD ["./main"]